package com.lu.pojo.container;

import java.util.Iterator;
import java.util.TreeMap;

/**
 * @author luzhenfang
 * @date 2020 07 04
 * @description  TreeMap 是有序的
 */
public class TetTreeMap {
    public static void main(String[] args) {
        TreeMap<Integer, String> map = new TreeMap<>();
        map.put(1,"jack");
        map.put(2,"tom");
        map.put(3,"rose");

        // 输出的 ThreeMap 是 有序的
        Iterator<Integer> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            System.out.println(map.get(iterator.next()));
        }

    }
}
